﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Mengsk.ERP.Orders;

namespace Mengsk.ERP.App
{
    /// <summary>
    /// OrderEdit.xaml 的交互逻辑
    /// </summary>
    public partial class OrderEdit : Window
    {
        public OrderFlag Flag { get; set; }

        public string Comment { get; set; }

        public OrderEdit()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.tbComment.Text = Comment;
            if (Flag == OrderFlag.BLUE)
            {
                this.rbBlue.IsChecked = true;
            }
            else if (Flag == OrderFlag.GREEN)
            {
                this.rbGreen.IsChecked = true;
            }
            else if (Flag == OrderFlag.PINK)
            {
                this.rbPink.IsChecked = true;
            }
            else if (Flag == OrderFlag.RED)
            {
                this.rbRed.IsChecked = true;
            }
            else if (Flag == OrderFlag.UN_LABEL)
            {
            }
            else if (Flag == OrderFlag.YELLOW)
            {
                this.rbYellow.IsChecked = true;
            }
            else
            {

            }
        }

        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            Flag = OrderFlag.UN_LABEL;
            if (this.rbBlue.IsChecked.Value)
            {
                Flag = OrderFlag.BLUE;
            }
            if (this.rbGreen.IsChecked.Value)
            {
                Flag = OrderFlag.GREEN;
            }
            if (this.rbPink.IsChecked.Value)
            {
                Flag = OrderFlag.PINK;
            }
            if (this.rbRed.IsChecked.Value)
            {
                Flag = OrderFlag.RED;
            }
            if (this.rbYellow.IsChecked.Value)
            {
                Flag = OrderFlag.YELLOW;
            }
            this.Comment = this.tbComment.Text.Trim();

            if (Flag == OrderFlag.UN_LABEL)
            {
                MessageBox.Show("选择颜色");
                return;
            }

            this.DialogResult = true;
        }
    }
}
